package com.mall.server.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.commons.utils.PageUtils;
import com.mall.dubbo.api.SmsFlashPromotionApi;
import com.tanhua.model.domain.SmsFlashPromotion;
import com.tanhua.model.vo.PageVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class FlashService {
    @DubboReference
    private SmsFlashPromotionApi smsFlashPromotionApi;

    /**
     * 根据活动名称分页查询
     * @param keyword
     * @param pageNum
     * @param pageSize
     * @return
     */
    public PageVo flashList(String keyword, Integer pageNum, Integer pageSize) {
        Page<SmsFlashPromotion> page = new Page<>(pageNum, pageSize);
        Page resultPage =smsFlashPromotionApi.flashList(keyword,page);
        return PageUtils.getPageVo(resultPage);
    }

    /**
     * 修改秒杀上下线
     * @param id
     * @param status
     * @return
     */
    public void updateStatus(Long id, Integer status) {
        smsFlashPromotionApi.updateStatus(id,status);
    }

    /**
     * 添加秒杀活动
     * @param smsFlashPromotion
     * @return
     */
    public void create(SmsFlashPromotion smsFlashPromotion) {
        smsFlashPromotionApi.create(smsFlashPromotion);
    }

    /**
     * 编辑秒杀活动
     * @param smsFlashPromotion
     */
    public void update(SmsFlashPromotion smsFlashPromotion) {
        smsFlashPromotionApi.update(smsFlashPromotion);
    }

    /**
     * 删除活动
     * @param id
     * @return
     */
    public void delete(Long id) {
        smsFlashPromotionApi.delete(id);
    }
}

